/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kasgroup2;

import java.awt.Component;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JSpinner;
import javax.swing.SpinnerDateModel;

/**
 *
 * @author beha
 */
public class UIRegisterPanel extends javax.swing.JPanel {

    private Hotel selectedHotel = null;
    private Room selectedRoom = null;
    private ArrayList<HotelRoomGuest> hotelRooms = null;
    private TableManager tmHotelsSelected = null;
    private TableManager tmHotelsAvailable = null;
    private TableManager tmActivities = null;
    private Conference selectedConference = null;
    
    /**
     * Creates new form UIRegisterPanel
     */
    public UIRegisterPanel() {
        initComponents();
        Date today = new Date();
        this.txtArrival.setText(CoreHandler.DateToString(today));
        this.txtDeparture.setText(CoreHandler.DateToString(today));
        this.hotelRooms = new ArrayList<HotelRoomGuest>();
        this.tmHotelsSelected = new TableManager(this.tblHotelsSelected);
        this.tmHotelsAvailable = new TableManager(this.tblHotelsAvailable);
        this.tmActivities = new TableManager(this.tblActivities);
        this.tmHotelsSelected.clear();
        this.tmHotelsAvailable.clear();
        this.tmActivities.clear();
        fillConferenceComboBox();
        fillConferenceActivitiesTable();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnlCompanionInfo = new javax.swing.JPanel();
        jLabel13 = new javax.swing.JLabel();
        txtCompanionFullname = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jScrollPane6 = new javax.swing.JScrollPane();
        tblActivities = new javax.swing.JTable();
        jPanel4 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        txtFullname = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        txtCity = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        txtCountry = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jScrollPane5 = new javax.swing.JScrollPane();
        txtAddress = new javax.swing.JTextArea();
        jPanel2 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        txtFirmName = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        txtPhoneHome = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        txtPhoneFirm = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        chkHasCompanion = new javax.swing.JCheckBox();
        chkWantHotel = new javax.swing.JCheckBox();
        jLabel16 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        chkIsSpeaker = new javax.swing.JCheckBox();
        jPanel5 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        cmbConference = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtConferenceInfo = new javax.swing.JTextArea();
        txtArrival = new javax.swing.JFormattedTextField();
        txtDeparture = new javax.swing.JFormattedTextField();
        jLabel17 = new javax.swing.JLabel();
        txtConferencePrice = new javax.swing.JFormattedTextField();
        jLabel20 = new javax.swing.JLabel();
        pnlHotels = new javax.swing.JPanel();
        pnlAvailableHotels = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblHotelsAvailable = new javax.swing.JTable();
        jLabel11 = new javax.swing.JLabel();
        cmbHotelRooms = new javax.swing.JComboBox();
        jLabel18 = new javax.swing.JLabel();
        btnAddHotel = new javax.swing.JButton();
        jLabel19 = new javax.swing.JLabel();
        pnlRoomService = new javax.swing.JPanel();
        chkRoomService = new javax.swing.JCheckBox();
        txtRoomServiceName = new javax.swing.JTextField();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        txtRoomServiceDescription = new javax.swing.JTextField();
        txtRoomServicePrice = new javax.swing.JFormattedTextField();
        txtRoomPrice = new javax.swing.JFormattedTextField();
        txtRoomAmount = new javax.swing.JFormattedTextField();
        pnlAvailableHotels1 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tblHotelsSelected = new javax.swing.JTable();
        btnRemoveHotel = new javax.swing.JButton();
        txtHotelRoomTotal = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        btnRegister = new javax.swing.JButton();
        lblCreationStatus = new javax.swing.JLabel();
        btnCancel = new javax.swing.JButton();
        jScrollPane4 = new javax.swing.JScrollPane();
        txtPriceInfo = new javax.swing.JTextArea();

        this.pnlCompanionInfo.setVisible(false);
        pnlCompanionInfo.setBorder(javax.swing.BorderFactory.createTitledBorder("Companion"));

        jLabel13.setText("Full name:");

        txtCompanionFullname.setText("forever alone");

        jLabel14.setText("Activities:");

        tblActivities.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"a", "stað 1", "Tue May 01 12:29:05 GMT+00:00 2012", "Tue May 01 12:29:05 GMT+00:00 2012", "1", "viðmerking 1", null},
                {"b", "stað 2", "Tue May 01 12:29:05 GMT+00:00 2012", "Tue May 01 12:29:05 GMT+00:00 2012", "2", "viðmerking 2", null},
                {"c", "stað 3", "Tue May 01 12:29:05 GMT+00:00 2012", "Tue May 01 12:29:05 GMT+00:00 2012", "3", "viðmerking 3", null},
                {"d", "stað 4", "Tue May 01 12:29:05 GMT+00:00 2012", "Tue May 01 12:29:05 GMT+00:00 2012", "4", "viðmerking 4", null}
            },
            new String [] {
                "Name", "Place", "From", "To", "Price", "Comment", "Use?"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Boolean.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, true
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tblActivities.setColumnSelectionAllowed(true);
        jScrollPane6.setViewportView(tblActivities);
        tblActivities.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        tblActivities.getColumnModel().getColumn(0).setResizable(false);
        tblActivities.getColumnModel().getColumn(1).setResizable(false);
        tblActivities.getColumnModel().getColumn(2).setResizable(false);
        tblActivities.getColumnModel().getColumn(3).setResizable(false);
        tblActivities.getColumnModel().getColumn(4).setResizable(false);
        tblActivities.getColumnModel().getColumn(5).setResizable(false);
        tblActivities.getColumnModel().getColumn(6).setResizable(false);

        org.jdesktop.layout.GroupLayout pnlCompanionInfoLayout = new org.jdesktop.layout.GroupLayout(pnlCompanionInfo);
        pnlCompanionInfo.setLayout(pnlCompanionInfoLayout);
        pnlCompanionInfoLayout.setHorizontalGroup(
            pnlCompanionInfoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pnlCompanionInfoLayout.createSequentialGroup()
                .addContainerGap()
                .add(pnlCompanionInfoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel13)
                    .add(jLabel14))
                .add(18, 18, 18)
                .add(pnlCompanionInfoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(txtCompanionFullname, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 223, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jScrollPane6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 1073, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnlCompanionInfoLayout.setVerticalGroup(
            pnlCompanionInfoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pnlCompanionInfoLayout.createSequentialGroup()
                .add(pnlCompanionInfoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel13)
                    .add(txtCompanionFullname, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(pnlCompanionInfoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(pnlCompanionInfoLayout.createSequentialGroup()
                        .add(12, 12, 12)
                        .add(jScrollPane6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                    .add(pnlCompanionInfoLayout.createSequentialGroup()
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel14)
                        .add(0, 97, Short.MAX_VALUE)))
                .addContainerGap())
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Participant Registration Information"));

        jLabel1.setText("Full name:");

        txtFullname.setText("Benjamin Hammer");

        jLabel2.setText("Address:");

        txtCity.setText("Tórshavn");

        jLabel3.setText("City:");

        txtCountry.setText("Føroyar");

        jLabel4.setText("Country:");

        txtAddress.setColumns(20);
        txtAddress.setLineWrap(true);
        txtAddress.setRows(3);
        txtAddress.setText("Mækjugøta 8");
        jScrollPane5.setViewportView(txtAddress);

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel1)
                            .add(jLabel2))
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jPanel1Layout.createSequentialGroup()
                                .add(19, 19, 19)
                                .add(txtFullname, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 205, Short.MAX_VALUE))
                            .add(jPanel1Layout.createSequentialGroup()
                                .add(25, 25, 25)
                                .add(jScrollPane5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))))
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel3)
                            .add(jLabel4))
                        .add(30, 30, 30)
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(txtCity)
                            .add(txtCountry))))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel1)
                    .add(txtFullname, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel2)
                    .add(jScrollPane5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel3)
                    .add(txtCity, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel4)
                    .add(txtCountry, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabel7.setText("Want Hotel?");

        txtFirmName.setText("Firma");

        jLabel8.setText("Firm Name:");

        txtPhoneHome.setText("123456");

        jLabel9.setText("Phone (home):");

        txtPhoneFirm.setText("654321");

        jLabel10.setText("Phone (firm):");

        chkHasCompanion.setText("(yes / no)");
        chkHasCompanion.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                hasCompanionChanged(evt);
            }
        });

        chkWantHotel.setText("(yes / no)");
        chkWantHotel.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                itemStateChangedWantHotel(evt);
            }
        });

        jLabel16.setText("Has Companion?");

        jLabel12.setText("Is speaker?");

        chkIsSpeaker.setText("(yes / no)");
        chkIsSpeaker.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                chkIsSpeakeritemStateChangedWantHotel(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel8)
                            .add(jLabel9)
                            .add(jLabel10))
                        .add(62, 62, 62)
                        .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, txtPhoneFirm)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, txtPhoneHome)
                            .add(txtFirmName)))
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                            .add(jPanel2Layout.createSequentialGroup()
                                .add(jLabel16)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .add(chkHasCompanion))
                            .add(jPanel2Layout.createSequentialGroup()
                                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(jLabel7)
                                    .add(jLabel12))
                                .add(77, 77, 77)
                                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(chkIsSpeaker)
                                    .add(chkWantHotel))))
                        .add(0, 68, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel8)
                    .add(txtFirmName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel9)
                    .add(txtPhoneHome, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel10)
                    .add(txtPhoneFirm, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(chkHasCompanion)
                    .add(jLabel16))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel7)
                    .add(chkWantHotel))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel12)
                    .add(chkIsSpeaker))
                .add(0, 13, Short.MAX_VALUE))
        );

        jLabel5.setText("Arrival:");

        jLabel6.setText("Departure:");

        jLabel15.setText("Conference:");

        cmbConference.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbConferenceActionPerformed(evt);
            }
        });
        cmbConference.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                cmbConferenceFocusGained(evt);
            }
        });

        txtConferenceInfo.setColumns(1);
        txtConferenceInfo.setEditable(false);
        txtConferenceInfo.setLineWrap(true);
        txtConferenceInfo.setRows(3);
        jScrollPane1.setViewportView(txtConferenceInfo);

        txtArrival.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("dd-MM-yyyy hh:mm"))));

        txtDeparture.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("dd-MM-yyyy hh:mm"))));

        jLabel17.setText("Price:");

        txtConferencePrice.setEditable(false);
        txtConferencePrice.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("dd-MM-yyyy hh:mm"))));

        jLabel20.setText("Info:");

        org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel5Layout.createSequentialGroup()
                        .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jPanel5Layout.createSequentialGroup()
                                .add(jLabel5)
                                .add(19, 19, 19))
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel5Layout.createSequentialGroup()
                                .add(jLabel6)
                                .add(18, 18, 18)))
                        .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(txtArrival)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, txtDeparture)))
                    .add(jPanel5Layout.createSequentialGroup()
                        .add(jLabel15)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(cmbConference, 0, 172, Short.MAX_VALUE))
                    .add(jPanel5Layout.createSequentialGroup()
                        .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel17)
                            .add(jLabel20))
                        .add(50, 50, 50)
                        .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane1)
                            .add(txtConferencePrice))))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel5)
                    .add(txtArrival, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(6, 6, 6)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel6)
                    .add(txtDeparture, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel15)
                    .add(cmbConference, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel17)
                    .add(txtConferencePrice, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel5Layout.createSequentialGroup()
                        .add(jLabel20)
                        .add(0, 0, Short.MAX_VALUE))
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE))
                .addContainerGap())
        );

        org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(0, 0, Short.MAX_VALUE))
            .add(jPanel4Layout.createSequentialGroup()
                .add(jPanel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        this.pnlHotels.setVisible(false);
        pnlHotels.setBorder(javax.swing.BorderFactory.createTitledBorder("Accomodation"));

        pnlAvailableHotels.setBorder(javax.swing.BorderFactory.createTitledBorder("Available Hotels"));

        tblHotelsAvailable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"Hotel Hafnia", "add. 1", null},
                {"Hotel Føroyar", "add. 2", null},
                {"Hotel Suðuroy", "add. 3", null},
                {"Hotel Øravík", "add. 4", null}
            },
            new String [] {
                "Hotel", "Address", "Rooms"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.Integer.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tblHotelsAvailable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblHotelsAvailableMouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(tblHotelsAvailable);
        tblHotelsAvailable.getColumnModel().getColumn(0).setResizable(false);
        tblHotelsAvailable.getColumnModel().getColumn(1).setResizable(false);
        tblHotelsAvailable.getColumnModel().getColumn(2).setResizable(false);

        jLabel11.setText("Room Type:");

        cmbHotelRooms.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbHotelRooms.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbHotelRoomsActionPerformed(evt);
            }
        });

        jLabel18.setText("Price:");

        btnAddHotel.setText("Add");
        btnAddHotel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddHotelActionPerformed(evt);
            }
        });

        jLabel19.setText("Amount:");

        pnlRoomService.setBorder(javax.swing.BorderFactory.createTitledBorder("Room Service"));

        chkRoomService.setText("Want room service");
        chkRoomService.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkRoomServiceActionPerformed(evt);
            }
        });

        txtRoomServiceName.setEditable(false);

        jLabel21.setText("Name:");

        jLabel22.setText("Price:");

        jLabel23.setText("Description:");

        txtRoomServiceDescription.setEditable(false);

        txtRoomServicePrice.setEditable(false);
        txtRoomServicePrice.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0.00"))));
        txtRoomServicePrice.setText("0.00");

        org.jdesktop.layout.GroupLayout pnlRoomServiceLayout = new org.jdesktop.layout.GroupLayout(pnlRoomService);
        pnlRoomService.setLayout(pnlRoomServiceLayout);
        pnlRoomServiceLayout.setHorizontalGroup(
            pnlRoomServiceLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pnlRoomServiceLayout.createSequentialGroup()
                .addContainerGap()
                .add(pnlRoomServiceLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(pnlRoomServiceLayout.createSequentialGroup()
                        .add(jLabel23)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(txtRoomServiceDescription))
                    .add(pnlRoomServiceLayout.createSequentialGroup()
                        .add(chkRoomService)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel21)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(txtRoomServiceName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 108, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel22)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(txtRoomServicePrice)))
                .addContainerGap())
        );
        pnlRoomServiceLayout.setVerticalGroup(
            pnlRoomServiceLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pnlRoomServiceLayout.createSequentialGroup()
                .add(pnlRoomServiceLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(chkRoomService)
                    .add(jLabel21)
                    .add(txtRoomServiceName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel22)
                    .add(txtRoomServicePrice, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pnlRoomServiceLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel23)
                    .add(txtRoomServiceDescription, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
        );

        txtRoomPrice.setEditable(false);
        txtRoomPrice.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0.00"))));
        txtRoomPrice.setText("0.00");

        txtRoomAmount.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));
        txtRoomAmount.setText("1");

        org.jdesktop.layout.GroupLayout pnlAvailableHotelsLayout = new org.jdesktop.layout.GroupLayout(pnlAvailableHotels);
        pnlAvailableHotels.setLayout(pnlAvailableHotelsLayout);
        pnlAvailableHotelsLayout.setHorizontalGroup(
            pnlAvailableHotelsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pnlAvailableHotelsLayout.createSequentialGroup()
                .addContainerGap()
                .add(pnlAvailableHotelsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(pnlRoomService, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 528, Short.MAX_VALUE)
                    .add(pnlAvailableHotelsLayout.createSequentialGroup()
                        .add(pnlAvailableHotelsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel11)
                            .add(jLabel18))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(pnlAvailableHotelsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(pnlAvailableHotelsLayout.createSequentialGroup()
                                .add(txtRoomPrice, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 148, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(jLabel19)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(txtRoomAmount))
                            .add(cmbHotelRooms, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, pnlAvailableHotelsLayout.createSequentialGroup()
                        .add(0, 0, Short.MAX_VALUE)
                        .add(btnAddHotel)
                        .add(13, 13, 13)))
                .addContainerGap())
        );
        pnlAvailableHotelsLayout.setVerticalGroup(
            pnlAvailableHotelsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pnlAvailableHotelsLayout.createSequentialGroup()
                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 98, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pnlAvailableHotelsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel11)
                    .add(cmbHotelRooms, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pnlAvailableHotelsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel19)
                    .add(jLabel18)
                    .add(txtRoomPrice, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(txtRoomAmount, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pnlRoomService, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(btnAddHotel))
        );

        pnlAvailableHotels1.setBorder(javax.swing.BorderFactory.createTitledBorder("Selected Hotels"));

        tblHotelsSelected.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"Hotel Hafnia", "add. 1", null, null, null, null, null},
                {"Hotel Føroyar", "add. 2", null, null, null, null, null},
                {"Hotel Suðuroy", "add. 3", null, null, null, null, null},
                {"Hotel Øravík", "add. 4", null, null, null, null, null}
            },
            new String [] {
                "Hotel", "Address", "Room Type", "Amount", "Price", "Room Service", "Total"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Double.class, java.lang.String.class, java.lang.Double.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tblHotelsSelected.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblHotelsSelectedMouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(tblHotelsSelected);
        tblHotelsSelected.getColumnModel().getColumn(0).setResizable(false);
        tblHotelsSelected.getColumnModel().getColumn(1).setResizable(false);
        tblHotelsSelected.getColumnModel().getColumn(2).setResizable(false);
        tblHotelsSelected.getColumnModel().getColumn(3).setResizable(false);
        tblHotelsSelected.getColumnModel().getColumn(4).setResizable(false);
        tblHotelsSelected.getColumnModel().getColumn(5).setResizable(false);
        tblHotelsSelected.getColumnModel().getColumn(6).setResizable(false);

        btnRemoveHotel.setText("Remove");
        btnRemoveHotel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRemoveHotelActionPerformed(evt);
            }
        });

        txtHotelRoomTotal.setText("0.0");

        org.jdesktop.layout.GroupLayout pnlAvailableHotels1Layout = new org.jdesktop.layout.GroupLayout(pnlAvailableHotels1);
        pnlAvailableHotels1.setLayout(pnlAvailableHotels1Layout);
        pnlAvailableHotels1Layout.setHorizontalGroup(
            pnlAvailableHotels1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pnlAvailableHotels1Layout.createSequentialGroup()
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(jScrollPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 474, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .add(pnlAvailableHotels1Layout.createSequentialGroup()
                .add(btnRemoveHotel)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(txtHotelRoomTotal)
                .add(18, 18, 18))
        );
        pnlAvailableHotels1Layout.setVerticalGroup(
            pnlAvailableHotels1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pnlAvailableHotels1Layout.createSequentialGroup()
                .add(jScrollPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pnlAvailableHotels1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(btnRemoveHotel)
                    .add(txtHotelRoomTotal))
                .addContainerGap())
        );

        org.jdesktop.layout.GroupLayout pnlHotelsLayout = new org.jdesktop.layout.GroupLayout(pnlHotels);
        pnlHotels.setLayout(pnlHotelsLayout);
        pnlHotelsLayout.setHorizontalGroup(
            pnlHotelsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pnlHotelsLayout.createSequentialGroup()
                .addContainerGap()
                .add(pnlAvailableHotels, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pnlAvailableHotels1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(123, Short.MAX_VALUE))
        );
        pnlHotelsLayout.setVerticalGroup(
            pnlHotelsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pnlHotelsLayout.createSequentialGroup()
                .addContainerGap()
                .add(pnlHotelsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(pnlAvailableHotels, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(pnlAvailableHotels1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Status"));

        btnRegister.setText("Create");
        btnRegister.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRegisterActionPerformed(evt);
            }
        });

        lblCreationStatus.setText("{save confirm status}");

        btnCancel.setText("Cancel");
        btnCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelActionPerformed(evt);
            }
        });

        txtPriceInfo.setColumns(20);
        txtPriceInfo.setEditable(false);
        txtPriceInfo.setRows(5);
        jScrollPane4.setViewportView(txtPriceInfo);

        org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel3Layout.createSequentialGroup()
                        .add(lblCreationStatus, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(302, 302, 302))
                    .add(jPanel3Layout.createSequentialGroup()
                        .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(jPanel3Layout.createSequentialGroup()
                                .add(btnCancel)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(btnRegister))
                            .add(jScrollPane4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(0, 0, Short.MAX_VALUE))))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .add(jScrollPane4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 106, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(lblCreationStatus)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(btnCancel)
                    .add(btnRegister)))
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(pnlHotels, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(layout.createSequentialGroup()
                        .add(jPanel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE))
                    .add(pnlCompanionInfo, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(jPanel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pnlCompanionInfo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pnlHotels, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void hasCompanionChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_hasCompanionChanged
        if(evt.getStateChange() == 1) {
            this.pnlCompanionInfo.setVisible(true);
        }
        else {
            this.pnlCompanionInfo.setVisible(false);
        }
    }//GEN-LAST:event_hasCompanionChanged

    private void itemStateChangedWantHotel(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_itemStateChangedWantHotel
        if(evt.getStateChange() == 1) {
            this.pnlHotels.setVisible(true);
        }
        else {
            this.pnlHotels.setVisible(false);
        }
        clearSelectedHotels();
        updateTotalPrice();
    }//GEN-LAST:event_itemStateChangedWantHotel

    /*private Object getTableCellValue(int row, int column, javax.swing.JTable table) {
        return table.getValueAt(row, column);
    }*/
    
    private void btnRegisterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRegisterActionPerformed
        
        try {
            Boolean success = KASGroup2.getCoreHandlerInstance().processRegistration(
                                    this.txtFullname.getText(),
                                    this.txtAddress.getText(),
                                    this.txtCity.getText(),
                                    this.txtCountry.getText(),
                                    this.txtFirmName.getText(),
                                    this.txtPhoneFirm.getText(),
                                    this.txtPhoneHome.getText(),
                                    this.txtArrival.getText(),
                                    this.txtDeparture.getText(),
                                    this.cmbConference.getSelectedItem(),
                                    this.chkHasCompanion.isSelected(),
                                    this.chkIsSpeaker.isSelected(),
                                    this.chkWantHotel.isSelected(),
                                    this.txtCompanionFullname.getText(),
                                    this.tmActivities,
                                    this.hotelRooms
                                    );
            if(success) {
                setStatus("Successfully created!");
                //clearFields();
            }
            else {
                setStatus("Something went wrong!");
            }
        } catch(Exception ex) {
            ex.printStackTrace();
            setStatus("Error: " + ex.getMessage());
        }
    }//GEN-LAST:event_btnRegisterActionPerformed

    private void cmbConferenceFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_cmbConferenceFocusGained
        fillConferenceComboBox();
    }//GEN-LAST:event_cmbConferenceFocusGained

    private void cmbConferenceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbConferenceActionPerformed
        //fillConferenceComboBox();
        Object selConferenceName = this.cmbConference.getSelectedItem();
        if(selConferenceName != null) {
            selectedConference = KASGroup2.getCoreHandlerInstance().getConference(selConferenceName.toString());
            fillConferenceInfo();
            fillConferenceActivitiesTable();
            fillConferenceHotelsTable();
            clearSelectedHotels();
            updateTotalPrice();
        }
    }//GEN-LAST:event_cmbConferenceActionPerformed

    private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
        clearFields();
    }//GEN-LAST:event_btnCancelActionPerformed

    private void chkIsSpeakeritemStateChangedWantHotel(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkIsSpeakeritemStateChangedWantHotel
        // TODO add your handling code here:
    }//GEN-LAST:event_chkIsSpeakeritemStateChangedWantHotel

    private void tblHotelsAvailableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblHotelsAvailableMouseClicked
        this.selectedHotel = KASGroup2.getCoreHandlerInstance().getHotel(tmHotelsAvailable.getCellValueForSelectedRow(0).toString());
        this.cmbHotelRooms.removeAllItems();
        for(Room r : this.selectedHotel.getRooms().keySet()) {
            this.cmbHotelRooms.addItem(r.getRoomType());
        }
    }//GEN-LAST:event_tblHotelsAvailableMouseClicked

    private void tblHotelsSelectedMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblHotelsSelectedMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_tblHotelsSelectedMouseClicked

    private void btnAddHotelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddHotelActionPerformed
        
        Room r = selectedRoom;
        //System.err.println("Room price: " + r.getRoomTotalPrice());
        //EnumRoomType rt = selectedRoom.getRoomType();
        //EnumRoomType rt = EnumRoomType.valueOf(this.cmbHotelRooms.getSelectedItem().toString());
        Double totalPriceForHotel = 0.0;
        Double roomServicePrice = 0.0;
        Double roomPrice = 0.0;
        int roomAmount = 0;
        //roomPrice = Double.parseDouble(this.txtRoomPrice.getText());
        //Room r = new Room(rt, roomPrice);
        roomAmount = Integer.parseInt(this.txtRoomAmount.getText());
        HotelRoomGuest hrg = new HotelRoomGuest(this.selectedHotel, r, roomAmount);
        this.hotelRooms.add(hrg);
        //roomPrice = Double.parseDouble(this.txtRoomPrice.getText());
        //roomPrice = roomAmount * roomPrice;//r.getRoomPrice();
        roomPrice = roomAmount * r.getRoomPrice();
        //roomServicePrice = Double.parseDouble(this.txtRoomServicePrice.getText());// r.getRoomServicePrice();
        roomServicePrice = roomAmount * r.getRoomServicePrice();
        totalPriceForHotel = roomPrice + roomServicePrice;
        
        
        this.tmHotelsSelected.addRow(new Object[] { this.selectedHotel.getName(), this.selectedHotel.getAddress(), r.getRoomType().toString(), roomAmount, roomPrice, roomServicePrice, totalPriceForHotel });
        updateTotalPrice();
    }//GEN-LAST:event_btnAddHotelActionPerformed

    private void cmbHotelRoomsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbHotelRoomsActionPerformed
        //System.out.println(this.selectedHotel.getName() + ", " +  this.cmbHotelRooms.getSelectedItem());
        this.selectedRoom = KASGroup2.getCoreHandlerInstance().getRoom(this.selectedHotel.getName(), this.cmbHotelRooms.getSelectedItem());
        //Object selRoom = this.cmbHotelRooms.getSelectedItem();
        if(this.selectedRoom != null) {
            RoomService rs = this.selectedRoom.getRoomService();
            if (rs != null) {
                this.txtRoomServicePrice.setText(rs.getPrice().toString());
                this.txtRoomServiceName.setText(rs.getName());
                this.txtRoomServiceDescription.setText(rs.getDescription());
            }
            //EnumRoomType selRoomType = EnumRoomType.valueOf(selRoom.getRoomType().toString());
            /*Iterator it = this.selectedHotel.getRooms().entrySet().iterator();
            while(it.hasNext()) {
                Map.Entry pairs = (Map.Entry)it.next();
                Room r = (Room)pairs.getKey();
                if(r.getRoomType().equals(selRoom.getRoomType())) {
                    selectedRoom = r;
                    break;
                }
            }
            System.out.println(selRoom.getRoomType() + " ?= " + selectedRoom.getRoomType());*/
            this.txtRoomPrice.setText(selectedRoom.getRoomPrice().toString());
            Integer roomAmount = 1;
            try {
                roomAmount = Integer.parseInt(this.txtRoomAmount.getText());
            }
            catch(Exception ex) {
                //do nothing
            }
            this.txtRoomAmount.setText(roomAmount.toString());
        }
    }//GEN-LAST:event_cmbHotelRoomsActionPerformed

    private void btnRemoveHotelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveHotelActionPerformed
        int selIndex = this.tmHotelsSelected.getSelectedRowIndex();
        if(selIndex >= 0 && this.hotelRooms.size() > selIndex) {
            this.hotelRooms.remove(selIndex);
            this.tmHotelsSelected.removeSelectedRow();
            updateTotalPrice();
        }
    }//GEN-LAST:event_btnRemoveHotelActionPerformed

    private void chkRoomServiceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkRoomServiceActionPerformed
        if(this.selectedRoom != null) {
            this.selectedRoom.setRoomServiceStatus(this.chkRoomService.isSelected());
        }
    }//GEN-LAST:event_chkRoomServiceActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAddHotel;
    private javax.swing.JButton btnCancel;
    private javax.swing.JButton btnRegister;
    private javax.swing.JButton btnRemoveHotel;
    private javax.swing.JCheckBox chkHasCompanion;
    private javax.swing.JCheckBox chkIsSpeaker;
    private javax.swing.JCheckBox chkRoomService;
    private javax.swing.JCheckBox chkWantHotel;
    private javax.swing.JComboBox cmbConference;
    private javax.swing.JComboBox cmbHotelRooms;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JLabel lblCreationStatus;
    private javax.swing.JPanel pnlAvailableHotels;
    private javax.swing.JPanel pnlAvailableHotels1;
    private javax.swing.JPanel pnlCompanionInfo;
    private javax.swing.JPanel pnlHotels;
    private javax.swing.JPanel pnlRoomService;
    private javax.swing.JTable tblActivities;
    private javax.swing.JTable tblHotelsAvailable;
    private javax.swing.JTable tblHotelsSelected;
    private javax.swing.JTextArea txtAddress;
    private javax.swing.JFormattedTextField txtArrival;
    private javax.swing.JTextField txtCity;
    private javax.swing.JTextField txtCompanionFullname;
    private javax.swing.JTextArea txtConferenceInfo;
    private javax.swing.JFormattedTextField txtConferencePrice;
    private javax.swing.JTextField txtCountry;
    private javax.swing.JFormattedTextField txtDeparture;
    private javax.swing.JTextField txtFirmName;
    private javax.swing.JTextField txtFullname;
    private javax.swing.JLabel txtHotelRoomTotal;
    private javax.swing.JTextField txtPhoneFirm;
    private javax.swing.JTextField txtPhoneHome;
    private javax.swing.JTextArea txtPriceInfo;
    private javax.swing.JFormattedTextField txtRoomAmount;
    private javax.swing.JFormattedTextField txtRoomPrice;
    private javax.swing.JTextField txtRoomServiceDescription;
    private javax.swing.JTextField txtRoomServiceName;
    private javax.swing.JFormattedTextField txtRoomServicePrice;
    // End of variables declaration//GEN-END:variables

    private void setStatus(String statusText) {
        this.lblCreationStatus.setText(statusText);
    }

    private void clearFields() {
        this.txtFullname.setText("");
        this.txtAddress.setText("");
        this.txtCity.setText("");
        this.txtCountry.setText("");
        this.txtFirmName.setText("");
        this.txtPhoneFirm.setText("");
        this.txtPhoneHome.setText("");
        this.txtArrival.setText("");
        this.txtDeparture.setText("");
        this.chkHasCompanion.setSelected(false);
        this.chkIsSpeaker.setSelected(false);
        this.txtCompanionFullname.setText("");
        this.lblCreationStatus.setText("");
        for(int i = 0; i < this.tmActivities.getRowCount(); i++) {
            this.tmActivities.setCellValue(false, i, 6);
        }
        /*for(int i = 0; i < this.tmHotelsAvailable.getRowCount(); i++) {
            this.tmHotelsAvailable.setCellValue(false, i, 3);
        }*/
        this.txtRoomPrice.setText("");
        this.tmHotelsSelected.clear();
    }

    private void fillConferenceComboBox() {
        try {
            this.cmbConference.removeAllItems();
            ArrayList<Conference> activeConferences = KASGroup2.getCoreHandlerInstance().getConferences(true);
            for(Conference c : activeConferences) {
                this.cmbConference.addItem(c.getName());
            }
        }
        catch(Exception ex) {
            ex.printStackTrace();
        }
    }

    private void fillConferenceInfo() {
        this.txtConferencePrice.setText(selectedConference.getPrice().toString());
        this.txtConferenceInfo.setText(selectedConference.getDescription());
    }

    private void fillConferenceActivitiesTable() {
        //Clear the table
        tmActivities.clear();
        if(selectedConference != null) {
            for(Activity a : selectedConference.getActivityList()) {
                String from = CoreHandler.DateToString(a.getStartTime());
                String to = CoreHandler.DateToString(a.getEndTime());
                tmActivities.addRow(new Object[] { a.getName(), a.getPlace(), from, to, a.getPrice(), a.getComment(), false });
            }
        }
        else {
            System.out.println("Conference is null!");
        }
    }
    
    private void fillConferenceHotelsTable() {
        //Clear the table
        tmHotelsAvailable.clear();
        if(selectedConference != null) {
            for(Hotel h : selectedConference.getHotelList()) {
                tmHotelsAvailable.addRow(new Object[] { h.getName(), h.getAddress(), h.getRoomCount(), false });
            }
        }
        else {
            System.out.println("Conference is null!");
        }
    }

    private void updateTotalPrice() {
        Double totalPrice = 0.0;
        Double hotelPrice = 0.0;
        for(HotelRoomGuest hrg : this.hotelRooms) {
            hotelPrice += hrg.getRoom().getRoomTotalPrice() * hrg.getAmount();
        }
        totalPrice = hotelPrice + this.selectedConference.getPrice();
        this.txtHotelRoomTotal.setText(hotelPrice.toString());
        StringBuilder sb = new StringBuilder();
        sb.append("Conference: " + this.selectedConference.getName());
        sb.append("\n");
        sb.append("Conference Price: \t" + this.selectedConference.getPrice());
        if(this.chkWantHotel.isSelected()) {
            sb.append("\n");
            sb.append("Hotel Price: \t\t" + hotelPrice);
        }
        sb.append("\n------\n");
        sb.append("Total Price: \t\t" + totalPrice.toString());
        sb.append("\n------\n");
        this.txtPriceInfo.setText(sb.toString());
    }

    private void clearSelectedHotels() {
        this.tmHotelsSelected.clear();
        this.hotelRooms.clear();
    }
}
